<?php if((isset($_SESSION['sys_admin']))||(isset($_SESSION['admin']))||(isset($_SESSION['intern_audit']))||(isset($_SESSION['second_consult']))||(isset($_SESSION['dept_pic']))) {?>

<script language="JavaScript" src="<?php echo base_url();?>js/FusionCharts.js"></script>



<style type="text/css">
	.opt {
		background:#FF9900;
		text-align:center;
	}
	.cd {
		width:600px;
		}
	
</style>
<?php
$x=date("Y");
$cx= $x.-10;
/*$jan = mysql_query("select count(*) as CANT from ticket where open_datetime like '%$cx%' and status='Open' order by ticket_id desc");
//var_dump(mysql_fetch_array($jan));
$fetch=  mysql_fetch_array($jan);
$jumlahrecord = $fetch['CANT'];
echo "Jumlah total record : " . $jumlahrecord;*/
$ql_average =mysql_query("select a.*,b.product,c.name,d.dept_name, count(*)/3 as ap   from (ticket a,product b,user c,dept d)  where a.prod_id=b.prod_id and a.user_id=c.user_id  and c.dept_id= d.dept_id and  severity_level in ('Medium','High','Low') group by product order by ticket_id desc");
$no =0;

?>



<link rel="stylesheet" href="<?php echo base_url();?>css/sorter/style.css" />
<div class="dashboard-atas">
<table cellpadding="0" cellspacing="0" border="0" id="table" class="sortable" class="cd">
	<thead>
		<tr>
				<th class="nosort"><h3>No</h3></th>
				<th><h3>Produk</h3></th>
				<th><h3>Dept</h3></th>
				<th><h3>Security Risk Average</h3></th>
				
		</tr>
	</thead>
	<tbody>
		<?php 
		$w1 ="#bee1ff";
		$w2 ="#90ccff";
		$warna = $w1;
		while($avg = mysql_fetch_array($ql_average)) {  
		if($warna==$w1) {
		$warna = $w2;
		} else {
			$warna = $w1;
			}
		$no++;?>
			
    <tr bgcolor=<?php echo $warna;?>>
	  <td><?php echo $no;?></td>
	  <td><?php echo $avg['product'];?></td>
	  <td><?php echo $avg['dept_name'];?></td>
	  <td><?php echo $avg['ap'];?></td>
	</tr> 
<?php } ?>
		
	</tbody>
	
</table>


</div>
<script type="text/javascript" src="<?php echo base_url();?>js/sorter.js"></script>
<script type="text/javascript">
	var sorter = new TINY.table.sorter("sorter");
		sorter.head="heads";
		sorter.asc = "asc";
		sorter.desc = "desc";
		sorter.even = "evenrow";
		sorter.odd = "oddrow";
		sorter.evensel ="evenselected";
		sorter.oddsel ="oddselected";
		sorter.paginate= true;
		sorter.currentid ="currentpage";
		sorter.limited ="pagelimit";
		sorter.init("table",1);
</script>


<div class="dashboard-chart">
<!-- ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -->
<div class="open-ticket">
	<div class="open-ticket-atas"><b>OPEN TICKET</b></div>
	<div class="open-ticket-tengah">
		<div id="chartdiv" align="center"> 
         </div>
      
	
	</div>
	<div class="open-ticket-bawah">Open By &nbsp;<select name="open" id="open">
			<option></option>
        	<option value="1">WEEK</option>
            <option value="2">MONTH</option>
            <option value="3">YEAR</option>
        </select>
		<script type="text/javascript">
	  		var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_Column3D.swf", "ChartId", "460", "350");
		   chart.setDataURL("<?php echo base_url();?>swf/grafik/cb.php");		   
		   chart.render("chartdiv");
	  
	  $('#open').change(function() {
	  	 if($('#open').val() == 3) {
		 	 var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_Column3D.swf", "ChartId", "460", "350");
		   chart.setDataURL("<?php echo base_url();?>swf/grafik/cb.php");		   
		   chart.render("chartdiv");
		   } else if($('#open').val() == 2) {
		   var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_Column3D.swf", "ChartId", "460", "350");
		   chart.setDataURL("<?php echo base_url();?>swf/grafik/creat_month.php");		   
		   chart.render("chartdiv");
		   }else if($('#open').val() == 1){
		   		var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_Column3D.swf", "ChartId", "460", "350");
		   chart.setDataURL("<?php echo base_url();?>swf/grafik/creat_day.php");		   
		   chart.render("chartdiv");
		   }
		}); 
		</script>
	</div>
</div>

<!-- ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -->
<div class="open-ticket2">
	<div class="open-ticket-atas"><b>CLOSED TICKET</b></div>
	<div class="open-ticket-tengah">
		<div id="chartdiv2" align="center"> 
         </div>
	</div>
	<div class="open-ticket-bawah">
		Open By &nbsp;<select name="tutup" id="tutup">
			<option></option>
        	<option value="1">WEEK</option>
            <option value="2">MONTH</option>
            <option value="3">YEAR</option>
        </select>
		<script type="text/javascript">
	  		var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_MSLine.swf", "ChartId", "460", "350");
			   chart.setDataURL("<?php echo base_url();?>swf/grafik/close_year.php");		   
			   chart.render("chartdiv2");
	  $('#tutup').change(function() {
		   	 if($('#tutup').val() == 3) {
				
			   var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_MSLine.swf", "ChartId", "460", "350");
			   chart.setDataURL("<?php echo base_url();?>swf/grafik/close_year.php");		   
			   chart.render("chartdiv2");
			 } else if($('#tutup').val() == 2) {
			 
			 		var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_MSLine.swf", "ChartId", "460", "350");
				   chart.setDataURL("<?php echo base_url();?>swf/grafik/close_month.php");		   
				   chart.render("chartdiv2");
			 
			 }else if($('#tutup').val() == 1){
				var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_MSLine.swf", "ChartId", "460", "350");
			   chart.setDataURL("<?php echo base_url();?>swf/grafik/close_week.php");		   
			   chart.render("chartdiv2");
			 }
		   
		   
		});
		</script>
	</div>
</div>

<!-- ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -->
<div class="open-ticket">
	<div class="open-ticket-atas"><b>BY DEPT</b></div>
	<div class="open-ticket-tengah">
		<div id="chartdiv3" align="center"> 
         </div>
	</div>
	<div class="open-ticket-bawah">
		Open By &nbsp;<select name="">
        	<option></option>
		<?php
			$dpt =mysql_query("select * from dept ");
			while($a_dpt=mysql_fetch_array($dpt)) {?>
				<option value="<?php echo $a_dpt['dept_name'];?>"><?php echo $a_dpt['dept_name'];?></option>
		<?php	} 
		?>
            </select>
			 <script type="text/javascript">
		   var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_Pie3D.swf", "ChartId", "460", "350");
		   chart.setDataURL("<?php echo base_url();?>swf/grafik/dept.php");		   
		   chart.render("chartdiv3");
		</script> </td>
	
	</div>
</div>


<!-- ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -->
<div class="open-ticket2">
	<div class="open-ticket-atas"><b>BY SEVERITY</b></div>
	<div class="open-ticket-tengah">
		<div id="chartdiv4" align="center"> 
         </div>
	</div>
	<div class="open-ticket-bawah">
		Open By &nbsp;<select name="sev" id="sev">
			<option></option>
        	<option value="1">WEEK</option>
            <option value="2">MONTH</option>
            <option value="3">YEAR</option>
        </select>
		<script type="text/javascript">
		   var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_StackedColumn3D.swf", "ChartId", "460", "350");
		   chart.setDataURL("<?php echo base_url();?>swf/grafik/sev.php");		   
		   chart.render("chartdiv4");
		   
		   $('#sev').change(function() {
				 if($('#sev').val() == 3) {
					
				   var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_StackedColumn3D.swf", "ChartId", "460", "350");
		  				 chart.setDataURL("<?php echo base_url();?>swf/grafik/sev_year.php");		   
		   				chart.render("chartdiv4");
				 } else if($('#sev').val() == 2) {
				 
						var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_StackedColumn3D.swf", "ChartId", "460", "350");
		  				 chart.setDataURL("<?php echo base_url();?>swf/grafik/sev.php");		   
		   				chart.render("chartdiv4");
				 
				 }else if($('#sev').val() == 1){
					var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_StackedColumn3D.swf", "ChartId", "460", "350");
		  				 chart.setDataURL("<?php echo base_url();?>swf/grafik/sev_week.php");		   
		   				chart.render("chartdiv4");
				 }
		   
		   
			});
		</script>
	</div>
</div>


<!-- ;;;;;;;;;;;;;;;;;;;;;;;;;;;; -->
<div class="open-ticket">
	<div class="open-ticket-atas"><b>BY PRODUCT</b></div>
	<div class="open-ticket-tengah">
		<div id="chartdiv5" align="center"> 
         </div>
	</div>
	<div class="open-ticket-bawah">
		Open By &nbsp;<select name="prods" id="prods">
		<option></option>
		<?php $ql_prod2 =mysql_query("select * from product order by prod_id desc");
				while($ql_prd_q =mysql_fetch_array($ql_prod2)) { 	
		?>
		
        	<option value="<?php echo $ql_prd_q['product'];?>"><?php echo $ql_prd_q['product'];?></option>
		<?php } ?>
            </select>
			<script type="text/javascript">
	  	var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_Pie3D.swf", "ChartId", "460", "350");
		chart.setDataURL("<?php echo base_url();?>swf/grafik/prod_ref.php");		 
		chart.render("chartdiv5");
		$(document).ready(function(){
		$('#prods').change(function() {
			$.post("<?php echo base_url();?>swf/grafik/prod.php/?cb="+$('#prods').val(),{data1:$('#prods').val()},
				function(o){
					  var x = o;
					  var chart = new FusionCharts("<?php echo base_url();?>swf/FCF_Pie3D.swf", "ChartId", "460", "350");
						/*chart.setDataURL("<?php echo base_url();?>swf/grafik/prod.php");*/
						 chart.setDataXML(o);
						chart.render("chartdiv5");
						
				}
				
			);
		});
		});
		</script>
	</div>
</div>
<?php } ?>
